using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using XFGameFramework;
using UnityEngine.UI;
public class PausePanel : Panel
{


    #region 字段
    [SerializeField] private Button btn_close;
    [SerializeField] private Button btn_setting;
    [SerializeField] private Button btn_save;
    [SerializeField] private Button btn_qsave;
    [SerializeField] private Button btn_back;
    [SerializeField] private Button btn_quit;



    private void Reset()
    {
        btn_close = transform.Find("btn_close").GetComponent<Button>();
        btn_setting = transform.Find("btn_setting").GetComponent<Button>();
        btn_save = transform.Find("btn_save").GetComponent<Button>();
        btn_qsave = transform.Find("btn_qsave").GetComponent<Button>();
        btn_back = transform.Find("btn_back").GetComponent<Button>();
        btn_quit = transform.Find("btn_quit").GetComponent<Button>();
    }

    #endregion
    private GameController gameController => Module.LoadController<GameController>();
    private GameSaveController gameSaveController => Module.LoadController<GameSaveController>();

    #region UI监听事件
    public void OnSettingClick()
    {
        Module.LoadPanel<SettingPanel>();
    }
    public void OnSaveClick()
    {
        GameSavePanel gameSavePanel = Module.LoadPanel<GameSavePanel>();
    }
    public void OnQSaveClick()
    {
        gameSaveController.CoverGameSave(gameController.GetCurrentArchiveIndex() , 0);
    }
    public void OnBackClick()
    {
        TipPanel tipPanel = Module.LoadPanel<TipPanel>();
        tipPanel.ShowTips("提示",
         "小斑鸠，你真的要返回主菜单吗？保存进度了吗",
         () =>
         {
             gameController.SetGameState(GameState.Start);
         },
         () => tipPanel.Close(),
  true,
  "是的喵",
  "点错了喵");
    }
    public void OnQuitClick()
    {
        TipPanel tipPanel = Module.LoadPanel<TipPanel>();
        tipPanel.ShowTips("提示",
         "小斑鸠，你真的要退出游戏吗？",
         () =>
         {
             Application.Quit();
#if UNITY_EDITOR
             UnityEditor.EditorApplication.isPlaying = false;
#endif
         },
         () => tipPanel.Close(),
  true,
  "是的喵",
  "并非退出");
    }
    public void OnCloseClick()
    {
        Close();
    }

    #endregion
}
